#ifndef TD_BASE_BUTTON_H_
#define TD_BASE_BUTTON_H_

/************************************************************************/
/* BOOST                                                                */
/************************************************************************/
#include "boost/function.hpp"

/************************************************************************/
/* PROJECT                                                              */
/************************************************************************/

/************************************************************************/
/* Core                                                                 */
/************************************************************************/
#include "Core/BaseEntity.h"
#include "Core/RectangleShape.h"

/************************************************************************/
/* GUI                                                                  */
/************************************************************************/
#include "GUI/Misc/Cursor.h"

/************************************************************************/
/* Resources                                                            */
/************************************************************************/
#include "Resources/ResourceManager.h"


using namespace boost;
using namespace TD_Core;

namespace TD_GUI {

	class BaseButton : public Tile {

		/************************************************************************/
		/* Static definitions                                                   */
		/************************************************************************/
		static const string m_defaultFont;
		static const unsigned int m_defaultFontSize;
		static const Color m_defaultFontColor;
		static const string m_defaultButtonFile;
	
		/** Callback pointers.*/
		function<int (const Coord2D & mousePos)> m_mouseOver;
		function<int (int mouseButton, const Coord2D & mousePos)> m_mouseClicked;


	public:

		/************************************************************************/
		/* ctors and dtors					                                    */
		/************************************************************************/
		//Default constructor
		explicit BaseButton();

		//Copy constructor
		explicit BaseButton(const BaseButton &rhs);

		//Assignment constructor
		BaseButton& operator=(const BaseButton &rhs);

		//Initialization constructor
		explicit BaseButton(const Coord2D &buttonPosition, const Coord2D &buttonSize);
		explicit BaseButton(const Coord2D &buttonPosition, const Coord2D &buttonSize, shared_ptr<SDLImage> g_pImage);

		//Destructor
		~BaseButton();


		/************************************************************************/
		/* Callbacks:                                                           */
		/************************************************************************/
		inline void setMouseOverCallback(function<int (const Coord2D & mousePos)> g_mouseOver) {
			m_mouseOver = g_mouseOver;
		}

		inline void setMouseClickedCallback(function<int (int mouseButton, const Coord2D & mousePos)> g_mouseClicked) {
			m_mouseClicked = g_mouseClicked;
		}

		static inline int defaultClick(int mouseButton, const Coord2D & mousePos) {
			//do notheeeing
			return 0;
		}

		static inline int defaultMouseOver(const Coord2D & mousePos) {
			//Change cursor
			SDLCursor::setCursor(handCursor);
			return 0;
		}

		inline int click(int mouseButton, const Coord2D & mousePos) {
			return(m_mouseClicked(mouseButton, mousePos));
			
		}

		inline int mouseOver(const Coord2D & mousePos) {
			return(m_mouseOver(mousePos));
		}

		/************************************************************************/
		/* Rendering                                                            */
		/************************************************************************/
		virtual void render(SDL_Surface *const g_destSurface, unsigned int deltaTime);
	};
}
#endif